home *** CD-ROM | disk | FTP | other *** search
- import java.io.ByteArrayInputStream;
- import java.io.ByteArrayOutputStream;
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.util.Random;
- import java.util.Vector;
- import javax.microedition.lcdui.Canvas;
- import javax.microedition.lcdui.Font;
- import javax.microedition.lcdui.Graphics;
- import javax.microedition.lcdui.Image;
-
- class JungleScreen extends Canvas {
- private static final boolean DEBUG = false;
- private static final int gtl = 20;
- private static final int CONST_levelIncrease = 150;
- private static final int CONST_levelIncreaseHC = 250;
- private int cheatIndex = 0;
- public static boolean cheatEnabled = false;
- private static final int[] cheatCode = new int[]{55, 55, 55, 55, 54, 54, 54, 51, 51, 51, 52, 52, 52, 50};
- private static final int[] cheatCode2 = new int[]{50, 57, 57, 57, 50, 50, 50, 50, 50, 56, 56, 56};
- private int width;
- private int height;
- private int gameMode;
- private int gameTimer;
- private boolean paused = false;
- private Image[] image;
- private Image[] hsImage;
- private Image dbufi;
- private Graphics dbufg;
- private Font font;
- private Font font2;
- private int[] blockFrame;
- private int[][] blockPos;
- private Vector bubble;
- private int playerPos;
- private int playerPosCounter;
- private int playerState;
- private int playerX;
- private int playerY;
- private int playerFrame;
- private boolean playerHasTreasure;
- private int playerGotTreasure = -1;
- private int score;
- private int lives;
- private int spiderX;
- private int spiderY;
- private int spiderState;
- private int spiderPos;
- private int stompState;
- private int stompPos;
- private int stompYPos;
- private int rightRockY;
- private int boxState;
- private int boxCounter;
- private int treasureType;
- private int treasureWas;
- private int numBlocks = 4;
- private int blockLimit1;
- private int blockLimit2;
- private int blockLimit3;
- private int bubbleDensity;
- private int spiderStaysStill;
- private final int _easyBlockLimit1 = 18;
- private final int _easyBlockLimit2 = 25;
- private final int _easyBlockLimit3 = 30;
- private final int _easyBubbleDensity = 20;
- private final int _easySpiderStaysStill = 50;
- private final int _hardBlockLimit1 = 10;
- private final int _hardBlockLimit2 = 15;
- private final int _hardBlockLimit3 = 20;
- private final int _hardBubbleDensity = 10;
- private final int _hardSpiderStaysStill = 20;
- private boolean notifyFromMenu = false;
- private Runko runko;
- private int levelIncrease;
- private int gLevel = 0;
- private boolean restart;
- private String[][] hsName = new String[3][10];
- private int[][] hsValue = new int[3][10];
- private static final String[] resource = new String[]{"logo", "hero", "blokit", "tasot", "txt_vesi", "intro", "info", "stomp"};
- private static Random rnd0 = new Random(System.currentTimeMillis());
- private long startsctm;
- private long Gsctm;
- private boolean tunnariPlayed = false;
-
- private static int random() {
- return rnd0.nextInt() >>> 1;
- }
-
- public void mode(int var1, int var2) {
- this.gameMode = var1;
- this.gameTimer = var2;
- this.playerGotTreasure = -1;
- }
-
- public JungleScreen(Runko var1) {
- this.runko = var1;
- }
-
- public Image[] getPics() {
- return this.hsImage;
- }
-
- public void hideNotify() {
- this.paused = true;
- if (!this.notifyFromMenu) {
- this.runko.showMenu(this);
- }
-
- }
-
- public void showNotify() {
- this.paused = false;
- this.notifyFromMenu = false;
- }
-
- public void exit() {
- this.restart = true;
- }
-
- public void init() {
- this.width = 96;
- this.height = 65;
- this.dbufi = Image.createImage(this.width, this.height);
- this.dbufg = this.dbufi.getGraphics();
- this.font = Font.getFont(64, 1, 8);
- this.font2 = Font.getFont(64, 0, 8);
- Runko.setProgressMax(resource.length + 2);
- this.image = new Image[resource.length];
-
- for(int var1 = 0; var1 < resource.length; ++var1) {
- try {
- this.image[var1] = Jil.loadImage(resource[var1]);
- Runko.addProgress();
- } catch (Exception var4) {
- ((Throwable)var4).printStackTrace();
- }
- }
-
- for(int var2 = 0; var2 < 10; ++var2) {
- this.hsName[0][var2] = this.hsName[1][var2] = this.hsName[2][var2] = "MrG";
- this.hsValue[0][var2] = this.hsValue[1][var2] = this.hsValue[2][var2] = 0;
- }
-
- this.loadHighScores();
- Runko.addProgress();
- this.hsImage = new Image[3];
-
- for(int var3 = 0; var3 < 3; ++var3) {
- this.hsImage[var3] = Image.createImage(this.width, 26 + this.font2.getHeight() * 10);
- this.updateHighScoreImage(this.hsImage[var3], var3, this.hsName[var3], this.hsValue[var3]);
- }
-
- MelodyManager.loadMelody(this.getClass().getResourceAsStream("sound.dat"), 203);
- Runko.addProgress();
- this.mode(42, 0);
- this.newGame();
- System.gc();
- }
-
- protected synchronized void paint(Graphics var1) {
- this.dbufg.setColor(16777215);
- this.dbufg.setClip(0, 0, this.width, this.height);
- this.dbufg.fillRect(0, 0, this.width, this.height);
- switch (this.gameMode) {
- case 0:
- case 5:
- case 69:
- Jil.drawSubImage(this.image[4], 0, 0, 101, 30, this.dbufg, (this.width >> 1) - 50, 0);
- int var12 = this.boxState == 1 ? 1 : 0;
- Jil.drawSubImage(this.image[2], 22 + var12 * 10, 38, 10, 14, this.dbufg, this.width - 10 + 3, 26 - (40 - this.rightRockY));
- this.drawSubImage(this.image[2], 11, 38, 11, 15, this.dbufg, -3, 40);
- this.drawSubImage(this.image[2], 0, 38, 11, 15, this.dbufg, this.width - 8, this.rightRockY);
-
- for(int var5 = -1; var5 < (this.width >> 4) + 2; ++var5) {
- this.drawSubImage(this.image[4], 65, 68, 16, 6, this.dbufg, var5 * 16 - this.gameTimer % 16, this.height - 15);
- }
-
- for(int var6 = 0; var6 < this.numBlocks; ++var6) {
- Jil.drawSubImage(this.image[3], 0, 12 * this.blockFrame[var6], 12, 12, this.dbufg, this.blockPos[var6][0] - 3, this.blockPos[var6][1]);
- }
-
- if (this.spiderState != 8 && this.spiderState != 9 && this.spiderState != 1 && this.spiderState != 2) {
- int var13 = this.gameTimer % 3 < 2 ? 0 : 1;
- Jil.drawSubImage(this.image[2], 0 + var13 * 18, 53, 18, 18, this.dbufg, this.spiderX + var13 - 3, this.spiderY);
- } else {
- Jil.drawSubImage(this.image[2], 36, 54, 15, 16, this.dbufg, this.spiderX - 3, this.spiderY + 2);
-
- for(int var7 = 0; var7 < (this.spiderY >> 2) + 1; ++var7) {
- Jil.drawSubImage(this.image[2], 31, 71, 2, 4, this.dbufg, this.spiderX - 3 + 6, var7 * 4);
- }
- }
-
- if (this.playerGotTreasure > -1 && this.gameTimer - this.playerGotTreasure < 10) {
- int var14 = 12 - (this.gameTimer - this.playerGotTreasure) * 4;
- if (var14 < 0) {
- var14 = -var14;
- }
-
- this.drawSubImage(this.image[3], 0, 96 + 11 * this.treasureType, 12, 11, this.dbufg, this.width - 10, var14);
- } else if (this.boxState == 1) {
- this.drawSubImage(this.image[3], 0, 96 + 11 * this.treasureType, 12, 11, this.dbufg, this.width - 10 + 2, 20);
- }
-
- this.drawSubImage(this.image[1], 0, 17 * this.playerFrame, 15, 17, this.dbufg, this.playerX - 3, this.playerY - 2);
- if (this.stompState != 0) {
- this.drawSubImage(this.image[7], 0, 0, this.image[7].getWidth(), this.image[7].getHeight(), this.dbufg, this.blockPos[this.stompPos][0] - 3 - 1, this.stompYPos);
- }
-
- for(int var15 = -1; var15 < this.width / 10 + 2; ++var15) {
- this.drawSubImage(this.image[4], 81, 68, 10, 9, this.dbufg, var15 * 10 + this.gameTimer % 10, this.height - 8);
- }
-
- for(int var8 = 0; var8 < this.bubble.size(); ++var8) {
- JungleScreen$Bubble var9 = (JungleScreen$Bubble)this.bubble.elementAt(var8);
- if (var9.y < this.height - 9) {
- if (var9.frame != 0 && var9.frame != 1) {
- this.drawSubImage(this.image[2], 8 + (var9.frame - 2) * 15, 71, var9.frame == 2 ? 8 : 7, 8, this.dbufg, var9.x - 3, var9.y);
- } else {
- this.drawSubImage(this.image[2], var9.frame * 16, 71, var9.frame == 0 ? 8 : 7, 8, this.dbufg, var9.x - 3, var9.y);
- }
- }
- }
-
- if (this.playerState == 0 && this.playerGotTreasure > -24 && this.playerGotTreasure < 0 && this.score != 0) {
- this.drawSubImage(this.image[3], 0, 129 + 11 * this.treasureWas, 12, 11, this.dbufg, 0, 14 + (this.playerGotTreasure -= 2));
- }
-
- if (this.playerHasTreasure) {
- Jil.drawSubImage(this.image[3], 0, 96 + 11 * this.treasureType, 12, 11, this.dbufg, 3, this.height - 11 - 3);
- }
-
- if (!cheatEnabled) {
- for(int var16 = this.lives; var16 > 0; --var16) {
- Jil.drawSubImage(this.image[2], 34, 71, 7, 7, this.dbufg, this.width - 20 + var16 * 4, this.height - 8);
- }
- }
-
- if (this.gameMode == 5) {
- if (this.gameTimer < 9) {
- this.drawSubImage(this.image[4], 0, 69, 64, 11, this.dbufg, (this.width >> 1) - 32, -12 + this.gameTimer * 4);
- } else {
- Jil.drawSubImage(this.image[4], 0, 69, 64, 11, this.dbufg, (this.width >> 1) - 32, 26);
- }
- }
-
- if (this.gameMode == 69) {
- Jil.drawSubImage(this.image[4], 57, 81, 40, 15, this.dbufg, (this.width >> 1) - 20, 16);
- }
-
- this.dbufg.setClip(0, 0, this.width, this.height);
- if (this.gameMode == 69 && this.gameTimer % 10 >= 5) {
- this.dbufg.setColor(0);
- this.dbufg.drawString("Press any key", (this.width >> 1) - (this.font.stringWidth("Press any key") >> 1) + 1, 30, 20);
- }
-
- this.dbufg.setColor(0);
- this.dbufg.setFont(this.font);
- this.dbufg.drawString("Score: " + String.valueOf(this.score), (this.width >> 1) - (this.font.stringWidth("Score: " + String.valueOf(this.score)) >> 1), this.height - this.font.getHeight(), 20);
- break;
- case 42:
- case 50:
- if (this.gameMode == 42) {
- this.dbufg.setClip(0, 0, this.width, this.height);
- this.dbufg.drawImage(this.image[0], (this.width >> 1) - (this.image[0].getWidth() >> 1) - 2, 0, 20);
- ++this.gameTimer;
- } else {
- this.dbufg.setClip(0, 0, this.width, this.height);
- this.dbufg.drawImage(this.image[6], (this.width >> 1) - (this.image[6].getWidth() >> 1), -4, 20);
- Jil.drawSubImage(this.image[2], 0, 0, 52, 30, this.dbufg, (this.width >> 1) - 26, this.image[6].getHeight() - 10);
- Jil.drawSubImage(this.image[2], 6, 33, 40, 5, this.dbufg, (this.width >> 1) - 20, this.gLevel == 0 ? this.image[6].getHeight() - 3 : this.image[6].getHeight() + 7);
- this.dbufg.setClip(0, 0, this.width, this.height);
- this.dbufg.setColor(0);
- Font var4;
- if (this.gLevel == 0) {
- var4 = this.font;
- } else {
- var4 = this.font2;
- }
-
- this.dbufg.setFont(var4);
- this.dbufg.drawString("easy", (this.width >> 1) - (var4.stringWidth("easy") >> 1), this.image[6].getHeight() - 5, 20);
- if (this.gLevel == 1) {
- var4 = this.font;
- } else {
- var4 = this.font2;
- }
-
- this.dbufg.setFont(var4);
- this.dbufg.drawString("hard", (this.width >> 1) - (var4.stringWidth("hard") >> 1), this.image[6].getHeight() + 5, 20);
- }
- break;
- case 49:
- this.dbufg.drawImage(this.image[5], (this.width >> 1) - (this.image[5].getWidth() >> 1), 0, 20);
- Jil.drawSubImage(this.image[2], 0, 0, 52, 30, this.dbufg, (this.width >> 1) - 26, this.image[5].getHeight() + 2);
- Jil.drawSubImage(this.image[2], 6, 33, 40, 5, this.dbufg, (this.width >> 1) - 20, this.gLevel == 0 ? this.image[5].getHeight() + 9 : this.image[5].getHeight() + 19);
- this.dbufg.setClip(0, 0, this.width, this.height);
- this.dbufg.setColor(0);
- Font var3;
- if (this.gLevel == 0) {
- var3 = this.font;
- } else {
- var3 = this.font2;
- }
-
- this.dbufg.setFont(var3);
- this.dbufg.drawString("start", (this.width >> 1) - (var3.stringWidth("start") >> 1), this.image[5].getHeight() + 8, 20);
- if (this.gLevel == 1) {
- var3 = this.font;
- } else {
- var3 = this.font2;
- }
-
- this.dbufg.setFont(var3);
- this.dbufg.drawString("help", (this.width >> 1) - (var3.stringWidth("help") >> 1), this.image[5].getHeight() + 18, 20);
- break;
- case 51:
- this.dbufg.setFont(this.font2);
- this.dbufg.setColor(0);
- int var2 = (int)((System.currentTimeMillis() - this.startsctm << 8) / 3000L * (long)(((Canvas)this).getHeight() + 10)) >> 8;
- this.dbufg.drawString("all your base", ((Canvas)this).getWidth() >> 1, var2, 17);
- this.dbufg.drawString("are belong to us!", ((Canvas)this).getWidth() >> 1, var2 + this.font2.getHeight(), 17);
- break;
- case 99:
- this.dbufg.setFont(this.font2);
- this.dbufg.setColor(0);
- this.dbufg.drawString("saving high scores", (((Canvas)this).getWidth() >> 1) - (this.font2.stringWidth("saving high scores") >> 1), (((Canvas)this).getHeight() >> 1) - this.font2.getHeight(), 20);
- this.dbufg.drawString("please wait...", (((Canvas)this).getWidth() >> 1) - (this.font2.stringWidth("please wait...") >> 1), (((Canvas)this).getHeight() >> 1) + this.font2.getHeight(), 20);
- }
-
- var1.drawImage(this.dbufi, (((Canvas)this).getWidth() >> 1) - (this.width >> 1), (((Canvas)this).getHeight() >> 1) - (this.height >> 1), 20);
- }
-
- public int run() {
- if (this.gameMode == 42) {
- this.newGame();
- this.mode(49, 0);
- this.gLevel = 0;
- }
-
- this.restart = false;
- this.gameTimer = 0;
-
- while(this.gameMode != 123 && !this.restart) {
- while(this.paused) {
- try {
- Thread.sleep(500L);
- } catch (InterruptedException var2) {
- }
- }
-
- switch (this.gameMode) {
- case 0:
- case 5:
- this.updatePlayer();
- this.updateRock();
- this.updateBlocks();
- this.updateBubbles();
- this.updateBox();
- this.updateSpider();
- this.updateStomp();
- case 49:
- case 50:
- default:
- break;
- case 69:
- this.updateBox();
- }
-
- ((Canvas)this).repaint();
- ((Canvas)this).serviceRepaints();
- ++this.gameTimer;
- if (!cheatEnabled && this.gameTimer % 150 == 149) {
- ++this.levelIncrease;
- } else if (cheatEnabled && this.gameTimer % 250 == 249) {
- ++this.levelIncrease;
- }
-
- Jil.setBacklight(true);
- Thread.yield();
- if (this.gameMode == 5 && System.currentTimeMillis() - this.Gsctm > 4000L) {
- this.mode(123, 0);
- }
- }
-
- if (!this.restart && this.checkHighScore(this.score) > -1) {
- this.notifyFromMenu = true;
- this.updateHighScore(this.score, this.runko.getName("New high score!", "Enter your name:"));
- if (cheatEnabled) {
- this.updateHighScoreImage(this.hsImage[2], 2, this.hsName[2], this.hsValue[2]);
- } else {
- this.updateHighScoreImage(this.hsImage[this.gLevel], this.gLevel, this.hsName[this.gLevel], this.hsValue[this.gLevel]);
- }
-
- this.mode(99, 0);
- ((Canvas)this).repaint();
- ((Canvas)this).serviceRepaints();
- Thread.yield();
- this.saveHighScores();
- }
-
- this.notifyFromMenu = true;
- this.newGame();
- if (this.restart) {
- this.newGame();
- this.mode(69, 0);
- return -1;
- } else {
- this.mode(42, 0);
- return cheatEnabled ? 2 : this.gLevel;
- }
- }
-
- private void updatePlayer() {
- switch (this.playerState) {
- case 0:
- if (this.numBlocks == 4) {
- this.playerX = this.playerPos * 19;
- } else {
- this.playerX = this.playerPos * 13;
- }
-
- switch (this.playerFrame) {
- case 0:
- this.playerX -= 5;
- break;
- case 1:
- this.playerX -= 4;
- break;
- case 2:
- this.playerX -= 5;
- break;
- case 3:
- this.playerX -= 3;
- break;
- case 4:
- this.playerX -= 5;
- break;
- case 5:
- this.playerX -= 3;
- }
-
- if (this.playerPos == 0) {
- this.playerY = 25;
- } else if (this.playerPos == this.numBlocks + 1) {
- this.playerY = 25 - (40 - this.rightRockY);
- } else {
- this.playerY = 27;
- }
-
- ++this.playerPosCounter;
- if (this.playerPos > 0 && this.playerPos < this.numBlocks + 1) {
- if (this.blockFrame[this.playerPos - 1] > 0) {
- this.playerState = 1;
- }
- } else if (this.playerPos == this.numBlocks + 1 && this.boxState == 1) {
- this.playerHasTreasure = true;
- this.playerGotTreasure = this.gameTimer;
- this.boxState = 2;
- this.score += 5;
- } else if (this.playerPos == 0 && this.playerHasTreasure) {
- this.playerHasTreasure = false;
- this.playerGotTreasure = -1;
- this.boxState = 0;
- if (!cheatEnabled) {
- switch (this.treasureType) {
- case 0:
- this.score += 10;
- break;
- case 1:
- this.score += 25;
- break;
- case 2:
- this.score += 100;
- }
- } else {
- this.score += 5;
- }
-
- this.treasureWas = this.treasureType;
- this.treasureType = -1;
- if (Runko.SoundOn) {
- MelodyManager.playMelody(4);
- }
- }
- break;
- case 1:
- this.playerY += 3;
- if (this.playerY > 70 && this.gameMode != 5) {
- --this.lives;
- if (this.lives > 0 && !cheatEnabled) {
- this.resetStuff();
- this.mode(69, 0);
- } else {
- this.Gsctm = System.currentTimeMillis();
- if (Runko.SoundOn) {
- MelodyManager.playMelody(1);
- }
-
- this.mode(5, 0);
- }
- }
-
- if (this.playerY < 40) {
- this.playerFrame = 6;
- } else {
- this.playerFrame = 7 + this.gameTimer % 2;
- }
- }
-
- }
-
- private void updateRock() {
- if (this.playerPos == this.numBlocks + 1 && this.playerPosCounter > 25) {
- if (this.playerPosCounter > 50) {
- this.keyPressed(52);
- this.rightRockY = 40;
- } else if (this.playerPosCounter > 40) {
- this.rightRockY += -3 + random() % 7;
- Jil.triggerVibrator(50);
- } else {
- this.rightRockY += -2 + random() % 5;
- Jil.triggerVibrator(35);
- }
-
- this.updatePlayer();
- } else {
- this.rightRockY = 40;
- }
-
- }
-
- private void updateBlocks() {
- int var1;
- int var2;
- int var3;
- if (!cheatEnabled) {
- var1 = this.blockLimit1 - (this.levelIncrease >> 1);
- var2 = this.blockLimit2 - (this.levelIncrease >> 1);
- var3 = this.blockLimit3 - (this.levelIncrease >> 1);
- } else {
- var1 = this.blockLimit1 - this.levelIncrease;
- var2 = this.blockLimit2 - this.levelIncrease;
- var3 = this.blockLimit3 - this.levelIncrease;
- }
-
- if (var1 < 3) {
- var1 = 3;
- }
-
- if (var2 < 5) {
- var2 = 5;
- }
-
- if (var3 < 7) {
- var3 = 7;
- }
-
- for(int var4 = 0; var4 < this.numBlocks; ++var4) {
- if (this.blockFrame[var4] != 0) {
- int var10002 = this.blockFrame[var4]++;
- if (this.blockFrame[var4] >= 8) {
- this.blockFrame[var4] = 0;
- }
- }
-
- if (this.blockPos[var4][1] >= 40) {
- int[] var10000 = this.blockPos[var4];
- var10000[1] += 3;
- } else if (this.playerPos - 1 == var4) {
- if (this.playerPosCounter > var1) {
- if (this.playerPosCounter < var2) {
- Jil.triggerVibrator(35);
- } else if (this.playerPosCounter <= var3) {
- Jil.triggerVibrator(50);
- }
-
- this.blockPos[var4][0] = this.getBlockPos(var4) - 1 + random() % 3;
- if (this.playerPosCounter > var2) {
- this.blockPos[var4][1] = 37 + random() % 3;
- if (this.playerPosCounter > var3) {
- this.blockPos[var4][0] = this.getBlockPos(var4);
- this.blockPos[var4][1] = 40;
- this.playerState = 1;
- }
- }
- }
- } else {
- this.blockPos[var4][0] = this.getBlockPos(var4);
- this.blockPos[var4][1] = 38;
- }
- }
-
- }
-
- private void updateBubbles() {
- for(int var1 = 0; var1 < this.bubble.size(); ++var1) {
- JungleScreen$Bubble var2 = (JungleScreen$Bubble)this.bubble.elementAt(var1);
- var2.update();
- if (var2.y <= 46 && var2.counter < 1) {
- if (var2.frame < 2) {
- var2.frame += 2;
- }
-
- ++var2.y;
- ++var2.counter;
- } else if (var2.y <= 46) {
- this.bubble.removeElementAt(var1);
- --var1;
- int var3 = 0;
-
- for(int var4 = 0; var4 < this.numBlocks; ++var4) {
- if (var2.x <= this.getBlockPos(var4) + 3) {
- var3 = var4;
- break;
- }
- }
-
- if (this.blockFrame[var3] == 0) {
- this.blockFrame[var3] = 1;
- if (Runko.SoundOn && this.gameMode != 5) {
- MelodyManager.playMelody(2);
- }
- }
- }
- }
-
- int var5 = this.bubbleDensity - (this.levelIncrease >> 1);
- if (var5 < 2) {
- var5 = 2;
- }
-
- if (random() % var5 == 0) {
- JungleScreen$Bubble var6 = new JungleScreen$Bubble(this, this.getBubbleRandom(), this.height, random() % 2, 0);
- this.bubble.addElement(var6);
- }
-
- }
-
- private void updateBox() {
- if (!cheatEnabled && this.gLevel == 0 && this.levelIncrease < 1 && this.boxState == 0) {
- this.boxState = 1;
- if (this.gameMode != 5) {
- MelodyManager.playMelody(3);
- }
-
- this.treasureType = 0;
- } else if (this.boxState != 2 && this.playerPos != this.numBlocks + 1 && this.boxCounter > 10 && (this.levelIncrease >= 1 || cheatEnabled) && random() % 20 == 0) {
- this.boxState = 1 - this.boxState;
- if (this.boxState == 1) {
- if (this.gameMode != 5) {
- MelodyManager.playMelody(3);
- }
-
- if (this.treasureType == -1) {
- if (!cheatEnabled) {
- int var1 = random() % 32;
- if (var1 < 4 && this.levelIncrease > 5) {
- this.treasureType = 2;
- } else if (var1 < 12 && this.levelIncrease > 3) {
- this.treasureType = 1;
- } else {
- this.treasureType = 0;
- }
- } else {
- this.treasureType = 0;
- }
- }
- }
-
- this.boxCounter = 0;
- }
-
- ++this.boxCounter;
- }
-
- private void updateSpider() {
- if (this.levelIncrease >= 3 || cheatEnabled) {
- byte var1 = 16;
- byte var2 = 73;
- if (this.numBlocks == 6) {
- var1 = 12;
- var2 = 77;
- }
-
- if (this.spiderState == 1) {
- if (this.spiderY > 10) {
- if (this.playerPos == 0) {
- this.playerState = 1;
- }
-
- this.spiderState = 2;
- } else {
- this.spiderY += 4;
- }
-
- } else if (this.spiderState == 2) {
- if (this.spiderY <= 0) {
- this.spiderY = 0;
- this.spiderState = 0;
- this.spiderPos = 1;
- } else {
- this.spiderY -= 2;
- }
-
- } else {
- if (this.spiderState == 3) {
- if (this.spiderX > 0) {
- this.spiderX -= 5;
- if (this.spiderX < 0) {
- this.spiderX = 0;
- }
-
- return;
- }
-
- if (this.spiderX <= 0) {
- this.spiderPos = 100;
- }
- } else if (this.spiderState == 8 || this.spiderState == 9) {
- if (this.spiderState == 8) {
- if (this.spiderY > 20) {
- this.spiderState = 9;
- } else {
- this.spiderY += 3;
- }
- } else if (this.spiderY <= 0) {
- this.spiderY = 0;
- this.spiderState = 0;
- int var3 = this.spiderStaysStill - this.levelIncrease * 4;
- if (var3 < 1) {
- var3 = 1;
- }
-
- this.spiderPos = 102 + random() % var3;
- } else {
- this.spiderY -= 2;
- if (this.spiderY < 0) {
- this.spiderY = 0;
- }
- }
-
- if (this.spiderY > 10 && (this.spiderX == this.getBlockPos(this.playerPos - 1) || this.spiderX + 1 == this.getBlockPos(this.playerPos - 1))) {
- this.spiderState = 9;
- this.playerState = 1;
- }
-
- return;
- }
-
- if (this.spiderPos <= 100 && this.spiderPos >= 80) {
- if (this.spiderX <= 0 && this.spiderPos != 1) {
- this.spiderState = 1;
- } else if (this.playerPos == 0 && this.spiderX >= 0) {
- this.spiderState = 3;
- } else if (this.spiderX <= var1) {
- this.spiderPos = 1;
- } else if (this.spiderX >= var2) {
- this.spiderPos = 0;
- } else {
- this.spiderPos = random() % 2;
- }
- }
-
- if (this.spiderPos == 0 && this.spiderX > var1) {
- this.spiderX -= 2;
- } else if (this.spiderPos == 1 && this.spiderX < var2) {
- this.spiderX += 2;
- } else if (this.spiderX <= var1 && this.playerPos == 0) {
- this.spiderPos = 1;
- }
-
- for(int var4 = 0; var4 < this.numBlocks; ++var4) {
- if ((this.spiderX == this.getBlockPos(var4) || this.spiderX + 1 == this.getBlockPos(var4)) && random() % 20 < 8 && this.spiderPos < 100 && this.spiderState != 3) {
- if (this.gameMode != 5) {
- MelodyManager.playMelody(5);
- }
-
- this.spiderState = 8;
- }
- }
-
- if (this.spiderPos > 100) {
- --this.spiderPos;
- }
-
- if (this.spiderX < 0) {
- this.spiderX = 0;
- } else if (this.spiderX > var2) {
- this.spiderX = var2;
- }
-
- }
- }
- }
-
- private void updateStomp() {
- if (this.stompState == 0 && this.treasureType == 2 && this.boxState == 2) {
- if (random() % 15 == 0) {
- this.stompState = 1;
- this.stompPos = random() % 3;
- this.stompYPos = -40;
- }
- } else if (this.stompState == 1) {
- this.stompYPos += 5;
- if (this.stompYPos > 0) {
- this.stompYPos = 0;
- this.stompState = 2;
- }
- } else if (this.stompState == 2) {
- this.stompYPos -= 2;
- if (this.stompYPos < -40) {
- this.stompState = 0;
- }
- }
-
- if (this.stompYPos > -13 && (this.stompPos == this.playerPos - 1 || this.stompPos + 1 == this.playerPos - 1)) {
- this.playerState = 1;
- }
-
- }
-
- private void newGame() {
- this.resetStuff();
- this.score = 0;
- this.lives = 3;
- if (this.gLevel != 0 && cheatEnabled) {
- this.blockLimit1 = 10;
- this.blockLimit2 = 15;
- this.blockLimit3 = 20;
- this.bubbleDensity = 10;
- this.spiderStaysStill = 20;
- } else {
- this.blockLimit1 = 18;
- this.blockLimit2 = 25;
- this.blockLimit3 = 30;
- this.bubbleDensity = 20;
- this.spiderStaysStill = 50;
- }
-
- if (this.gLevel != 0 && !cheatEnabled) {
- this.levelIncrease = 4;
- } else {
- this.levelIncrease = 0;
- }
-
- System.gc();
- }
-
- private void resetStuff() {
- this.playerPos = this.playerState = 0;
- this.playerX = -3;
- this.playerY = 25;
- this.playerFrame = 3 + random() % 3;
- this.playerHasTreasure = false;
- this.playerGotTreasure = -1;
- this.boxState = 0;
- this.boxCounter = 0;
- this.treasureType = -1;
- this.treasureWas = -777;
- this.spiderX = 80;
- this.spiderY = 0;
- this.spiderState = this.spiderPos = 0;
- this.stompState = 0;
- this.stompYPos = -40;
- this.rightRockY = 40;
- this.blockFrame = new int[this.numBlocks];
- this.blockPos = new int[this.numBlocks][2];
-
- for(int var1 = 0; var1 < this.numBlocks; ++var1) {
- this.blockPos[var1][0] = this.getBlockPos(var1);
- this.blockPos[var1][1] = 38;
- this.blockFrame[var1] = 0;
- }
-
- this.bubble = new Vector();
- }
-
- private int getBlockPos(int var1) {
- return this.numBlocks == 4 ? 16 + var1 * 19 : 12 + var1 * 13;
- }
-
- private int getBubbleRandom() {
- return this.numBlocks == 4 ? 19 + random() % 4 * 19 : 15 + random() % 6 * 13;
- }
-
- protected void keyPressed(int var1) {
- if (Jil.isMenuKey(var1)) {
- this.paused = true;
- this.notifyFromMenu = true;
- this.runko.showMenu(this);
- } else {
- if (this.gameMode == 69) {
- this.mode(0, 0);
- ((Canvas)this).repaint();
- return;
- }
-
- if (this.gameMode == 49) {
- if (var1 == cheatCode[this.cheatIndex]) {
- if (++this.cheatIndex == cheatCode.length) {
- Runko.soundSelect();
- if (cheatEnabled) {
- cheatEnabled = false;
- this.cheatIndex = 0;
- this.numBlocks = 4;
- this.newGame();
- return;
- }
-
- cheatEnabled = true;
- this.cheatIndex = 0;
- this.numBlocks = 6;
- this.mode(51, 0);
- this.startsctm = System.currentTimeMillis();
-
- while(System.currentTimeMillis() - this.startsctm < 3000L) {
- ((Canvas)this).repaint();
- ((Canvas)this).serviceRepaints();
- Thread.yield();
- }
-
- this.gLevel = 1;
- this.newGame();
- this.mode(69, 0);
- return;
- }
- } else {
- this.cheatIndex = 0;
- }
-
- if (((Canvas)this).getGameAction(var1) != 1 && ((Canvas)this).getGameAction(var1) != 6) {
- if (((Canvas)this).getGameAction(var1) == 8 || var1 == 53) {
- Runko.soundSelect();
- if (this.gLevel == 0) {
- if (cheatEnabled) {
- this.gLevel = 1;
- this.newGame();
- this.mode(69, 0);
- return;
- }
-
- this.mode(50, 0);
- } else {
- this.notifyFromMenu = true;
- this.runko.showHelp(this);
- }
-
- this.gLevel = 0;
- }
- } else {
- Runko.soundMove();
- this.gLevel = 1 - this.gLevel;
- }
- } else if (this.gameMode == 50) {
- if (((Canvas)this).getGameAction(var1) != 1 && ((Canvas)this).getGameAction(var1) != 6) {
- if (((Canvas)this).getGameAction(var1) == 8 || var1 == 53) {
- MelodyManager.playMelody(6);
- this.newGame();
- this.mode(69, 0);
- }
- } else {
- Runko.soundMove();
- this.gLevel = 1 - this.gLevel;
- }
- } else {
- if (!cheatEnabled) {
- if (var1 == cheatCode2[this.cheatIndex]) {
- if (++this.cheatIndex == cheatCode2.length) {
- Runko.soundSelect();
- ++this.lives;
- this.cheatIndex = 0;
- }
- } else {
- this.cheatIndex = 0;
- }
- }
-
- if (((Canvas)this).getGameAction(var1) != 2 && var1 != 52) {
- if (((Canvas)this).getGameAction(var1) == 5 || var1 == 54) {
- this.keyPressedRight();
- }
- } else {
- this.keyPressedLeft();
- }
- }
- }
-
- }
-
- protected void keyReleased(int var1) {
- }
-
- private void keyPressedLeft() {
- if (this.playerState == 0 && this.playerPos > 0) {
- --this.playerPos;
- this.playerPosCounter = 0;
- if (this.playerPos == 0) {
- this.playerFrame = 3 + random() % 3;
- } else {
- this.playerFrame = random() % 3;
- }
-
- this.updatePlayer();
- }
-
- }
-
- private void keyPressedRight() {
- if (this.playerState == 0 && (this.playerPos < this.numBlocks + 1 && this.boxState == 1 || this.playerPos < this.numBlocks)) {
- ++this.playerPos;
- this.playerPosCounter = 0;
- if (this.playerPos == this.numBlocks + 1) {
- this.playerFrame = random() % 3;
- } else {
- this.playerFrame = 3 + random() % 3;
- }
-
- this.updatePlayer();
- }
-
- }
-
- private void loadHighScores() {
- try {
- byte[] var1 = Jil.loadData("FJungle");
- ByteArrayInputStream var2 = new ByteArrayInputStream(var1);
- DataInputStream var3 = new DataInputStream(var2);
-
- for(int var4 = 0; var4 < this.hsName.length; ++var4) {
- for(int var5 = 0; var5 < this.hsName[var4].length; ++var5) {
- this.hsName[var4][var5] = var3.readUTF();
- this.hsValue[var4][var5] = var3.readInt();
- }
- }
- } catch (Exception var6) {
- this.saveHighScores();
- }
-
- }
-
- private void saveHighScores() {
- try {
- ByteArrayOutputStream var1 = new ByteArrayOutputStream();
- DataOutputStream var2 = new DataOutputStream(var1);
-
- for(int var3 = 0; var3 < this.hsName.length; ++var3) {
- for(int var4 = 0; var4 < this.hsName[var3].length; ++var4) {
- var2.writeUTF(this.hsName[var3][var4]);
- var2.writeInt(this.hsValue[var3][var4]);
- }
- }
-
- Jil.saveData("FJungle", var1.toByteArray());
- } catch (Exception var5) {
- }
-
- }
-
- private int checkHighScore(int var1) {
- for(int var2 = 0; var2 < 10; ++var2) {
- if (var1 > this.hsValue[this.gLevel][var2]) {
- return var2;
- }
- }
-
- return -1;
- }
-
- private void updateHighScore(int var1, String var2) {
- int var3 = this.gLevel;
- if (cheatEnabled) {
- var3 = 2;
- }
-
- for(int var4 = 0; var4 < 10; ++var4) {
- if (var1 > this.hsValue[var3][var4]) {
- for(int var5 = 9; var5 > var4; --var5) {
- this.hsName[var3][var5] = this.hsName[var3][var5 - 1];
- this.hsValue[var3][var5] = this.hsValue[var3][var5 - 1];
- }
-
- this.hsName[var3][var4] = var2;
- this.hsValue[var3][var4] = var1;
- System.gc();
- return;
- }
- }
-
- }
-
- private void updateHighScoreImage(Image var1, int var2, String[] var3, int[] var4) {
- Graphics var5 = var1.getGraphics();
- var5.setFont(this.font2);
- var5.setColor(16777215);
- var5.fillRect(0, 0, var1.getWidth(), var1.getHeight());
- var5.setColor(0);
- if (var2 != 2) {
- Jil.drawSubImage(this.image[4], 0, 30 + (1 - var2) * 19, 101, 19, var5, (this.width >> 1) - 50, 0);
- } else {
- var5.drawString("HARDCORE!", ((Canvas)this).getWidth() >> 1, 5, 17);
- }
-
- var5.setClip(0, 0, var1.getWidth(), var1.getHeight());
- int var6 = this.font.stringWidth("10.") + 2;
- int var7 = var1.getWidth() - 8;
- byte var8 = 24;
- int var9 = 0;
-
- for(int var10 = 2 + var8 + this.font.getBaselinePosition(); var9 < 10; var10 += this.font.getHeight()) {
- var5.drawString(Integer.toString(var9 + 1) + ".", var6, var10, 72);
- var5.drawString(var3[var9], var6 + 1, var10, 68);
- var5.drawString(Integer.toString(var4[var9]), var7, var10, 72);
- int var11 = var7 - this.font.stringWidth(Integer.toString(var4[var9])) - 2;
- int var12 = (var6 + 7 + this.font.stringWidth(var3[var9])) / 5 * 5;
- if (var12 < var11) {
- while(var12 < var11) {
- var5.drawLine(var12, var10, var12, var10);
- var12 += 5;
- }
- }
-
- ++var9;
- }
-
- }
-
- private void drawSubImage(Image var1, int var2, int var3, int var4, int var5, Graphics var6, int var7, int var8) {
- if ((var8 >= 0 || var8 + var5 > 0) && var8 < this.height) {
- if (var7 < 0) {
- var2 -= var7;
- var4 += var7;
- var7 = 0;
- } else {
- if (var7 > this.width) {
- return;
- }
-
- if (var7 + var4 > this.width) {
- var4 -= var4 + var7 - this.width;
- if (var4 <= 0) {
- return;
- }
- }
- }
-
- if (var8 < 0) {
- var3 -= var8;
- var5 += var8;
- var8 = 0;
- } else if (var5 > this.height) {
- var5 = this.height;
- }
-
- Jil.drawSubImage(var1, var2, var3, var4, var5, var6, var7, var8);
- }
- }
- }
-